package event

import heap.EventNotifiable

class EventObjectFree(list: List<String>) : Event() {
    companion object {
        const val TYPE = "ObjectFree"
        const val KEY_TAG = "Tag"
        const val KEY_SIGNATURE = "Signature"
    }

    var tag = 0
    lateinit var signature: String

    init {
        list.forEach {
            val entry = it.split('=')
            when(entry[0]) {
                KEY_SIGNATURE -> signature = entry[1]
                KEY_TAG -> tag = entry[1].toInt()
            }
        }
    }

    override fun toString(): String {
        return "EventObjectFree(tag=$tag, signature='$signature')"
    }

    override fun notifyTHeap(notifiable: EventNotifiable) {
        notifiable.receiveNotify(this)
    }
}